Skip to main content

Studies Templates Repository

Repository stores user's list of indicators templates.

Repository interface:

/**
* Interface for a repository to store data about user-created templates of indicators.
*
* Implementation of this interface is mandatory for the library to function. It is passed to [com.devexperts.dxcharts.lib.domain.DxChartsConfig].
*
* Standard implementation: [com.devexperts.dxcharts.lib.data.repo.default_repos.DefaultStudiesTemplatesRepository]
*/
interface StudiesTemplatesRepository {
/**
* Method to add or remove a template to the list of enabled templates.
*/
fun toggleTemplate(template: TemplatesModel)
/**
* Method to save a new template.
*/
fun saveTemplate(template: TemplatesModel)
/**
* Method to remove a template by [templateId].
*/
fun removeTemplate(templateId: String)
/**
* Method to update an existing template.
*/
fun updateTemplate(template: TemplatesModel)
/**
* Method to check if a template name is occupied.
*
* @return true - if the name is occupied, false - if it's free
*/
fun isTemplateNameOccupied(templateName: String): Boolean
/**
* Method to get all templates.
*/
fun getTemplates(): List<TemplatesModel>
/**
* Method to get templates that have been added to the list of enabled templates.
*/
fun getSelectedTemplate(): TemplatesModel?
/**
* Method to get a template by its [id].
*
* @return the template if it exists, null - if it doesn't exist
*/
fun findTemplateById(id: String): TemplatesModel?
/**
* Method to remove a template from the list of enabled templates.
*/
fun deselectTemplate()
}

TemplatesModel class used in the repository:

data class TemplatesModel (
val id: String = "",
var name: String = "",
val studies: MutableList<StudiesSetting> = mutableListOf()
)